define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'store.goods_coupon/index',
        add_url: 'store.goods_coupon/add',
        edit_url: 'store.goods_coupon/edit',
        delete_url: 'store.goods_coupon/delete',
        export_url: 'store.goods_coupon/export',
        modify_url: 'store.goods_coupon/modify',
    };

    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    {field: 'title', title: '名称'},
                    {field: 'coupon_price', title: '面额'},
                    {field: 'use_min_price', title: '最低消费'},
                    {field: 'coupon_time', title: '有效期限（单位：天）'},
                    {field: 'start_time', title: '开启时间'},
                    {field: 'end_time', title: '结束时间'},
                    {field: 'total_count', title: '领取数量'},
                    {field: 'remain_count', title: '剩余领取数量'},
                    {field: 'status', title: '状态', templet: function (d) {
                            return ea.table.switch({id: d.status, status: d.status}, {
                                tips: '正常|关闭',
                                checked: d.status,
                                field: 'status'
                            })
                        }},
                    {field: 'sort', title: '排序', edit: 'text'},
                    {field: 'create_time', title: '创建时间'},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };

    return Controller;
});